package main

import (
	"fmt"
	"os"
	"text/template"
)

/*
type Movie struct {
	Title    string
	Year     int
	Color    bool
	Actors   []string
	duration int
}
*/

type Movie struct {
	Title    string   `json:"title"`
	Year     int      `json:"release"`
	Color    bool     `json:"color"`
	Actors   []string `json:"actors"`
	duration int
}

func main() {
	movies := []Movie{
		{"Casablanca", 1942, false, []string{"Humphrey Bogart", "Ingrid Bergman"}, 1000},
		{"Cool Hand Luke", 1967, true, []string{"Paul Newman"}, 1258},
		{"Bullitt", 1968, true, []string{"Steve McQueen", "Jacqueline Bisset"}, 2389},
	}

	tmpl, err := template.New("text").
		Parse("{{range .}}{{.Title}} release in {{.Year}}. Actors:{{range .Actors}}{{.}},{{end}}\n{{end}}")
	if err != nil {
		fmt.Printf("%v\n", err)
		return
	}
	err = tmpl.Execute(os.Stdout, movies)

	if err != nil {
		fmt.Printf("%v\n", err)
		return
	}
}
